function checktextarea()
{
var jd=true;
var c=document.getElementById("kehuxingming").value;
var x=document.getElementById("shengaohao").value;
var y=document.getElementById("lianxihao").value;
var z=document.getElementById("xdlb").value;
if(x==""||isNaN(x))
	{
		alert("你输入的申告号码不是数字！");
		jd = false;
	}else if(y==""||isNaN(y)){
		alert("你输入的联系电话不是数字！");
		jd = false;
	}else if(z=="请选择..."){
		alert("请选择你要登记的类别，以便处理人员判断！");
		jd = false;
	}else if(c==""){
		alert("请务必输入客户姓名！");
		jd = false;
	}
return jd;
}
function cleantextarea(){
	$("#kehuxingming").val("")
	$("#shengaohao").val("")
	$("#lianxihao").val("")
	$("#xdlb").val("")
	$("#fuwuneirong").val("")
	$("#cridnumber").val("")
	$("#craddress").val("")
}
function openviewcontendailog()
{
	window.open ('index.php', 'newwindow', 'height=700, width=1024, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
}
function gdsubmit(){
    if(checktextarea()!=false){
        $.post("index.php?s=/Npfe/Xiadan/SubmitGD.html",$("#xdf").serialize(),function(data){
        	if(data=='1'){
        		alert("下单成功");
        		$("#maindlg").dialog('close');
        	}else{
        		alert("下单失败，请稍后再试。");
        	}
        });
    }
}
function checkgdsubmit(){
	$.post("index.php?s=/Home/Complain/chekgdlb.html",$("#gdlb").serialize(),function(data){
		jsonr = eval("("+data+")");
		$("#gdlist").datagrid('loadData',jsonr);
	})
}
function checkjhsubmit(){
	$.post("index.php?s=/Home/Complain/chekjhlb.html",$("#gdlb").serialize(),function(data){
		jsonr = eval("("+data+")");
		$("#gdlist").datagrid('loadData',jsonr);
	})
}
function checkrep(){
    lx = $("#lianxihao").val();
    $.post("index.php?s=/Npfe/Xiadan/CheckRep.html",{lianxihao:lx},function(data){
    	switch(data){
    	case 'rep':
    		alert('你输入联系电话号码，之前已经登记过工单，请检查前单确认是否需要重新下单！');
    		break;
    	case 'rep&runing':
    		alert('你输入联系电话号码，已经登记过工单并且状态为处理中，只能追加内容！');
    		changetocc(lx);
    		break;
    	}
    }); 
}
function changetocc(lxdh){
	$('#xdtabs').tabs('select','追加、催促内容');
	$('#cclx').val(lxdh);
	$('#gdsbtn').html('');
}
function fastnewgd() {
    $("#maindlg").dialog({
        title: '新建工单',
        width: 800,
        height: 470,
        closed: false,
        cache: false,
        href: 'index.php?s=/Npfe/Xiadan/index.html',
        modal: true,
        onClose: function(){UE.getEditor('fuwuneirong').destroy();}
    });
}
function viewgd(cn,time){
	$("#dlg1").dialog({
            title: '查看工单内容',
            width: 800,
            height: 600,
            closed: false,
            cache: false,
            href: 'index.php?s=/Npfe/Gdc/viewgd/cn/'+cn+'/time/'+time,
            modal: true,
            toolbar: [{
                    text:'重载',
                    iconCls:'icon-reload',
                    handler:function(){
                        viewgd(cn,time);
                    }
                }]
        });
}
function dvzthhgd(cn,time){
	$(".sipg").html("<div class=\"sipg\">正在加载</div>")
	$.get("./gongdan/get.php?action=zthh&cn="+cn+"&time="+time,function(data){
		$(".vgdp").html(data)
	})
}
function submitzthhgd(cn,time){
	$(".sipg").append("<div class=\"sipg\">正在发送...</div>")
	$.post("./gongdan/get.php?action=submitzthhgd&cn="+cn+"&time="+time,$("#zth").serialize(),function(data){
		$(".sipg").html(data)
	})
}
function sumbitgdpg(cn,time){
	$(".sipg").append("<div class=\"sipg\">正在发送...</div>")
	$.post("./gongdan/get.php?action=sumbitprogress&cn="+cn+"&time="+time,$("#wgdpg").serialize(),function(data){
		$(".sipg").html(data)
	})
}
function updatezthhgd(cn,time){
	$(".sipg").append("<div class=\"sipg\">正在发送...</div>")
	$.post("./gongdan/get.php?action=updatezthhgd&cn="+cn+"&time="+time,$("#zth").serialize(),function(data){
		$(".sipg").html(data)
	})
}
function updatehj(cn,time){
	$(".sipg").html("<div class=\"sipg\">正在切换到环节编辑...</div>")
	$.get("./gongdan/get.php?action=updatehj&cn="+cn+"&begintime="+time,function(data){
		$(".vgdp").html(data)
	})
}
function swe(){
	if ($("#xdlb").val()=="投诉-产品质量") {
		$("#cnt").css("display","none")
		$("#ycl").css("display","block")
		$.get("int.php?action=yclp&value=begin",function(data){
			$("#tpl-ycl").html(data)
		})
	}else {
		yclclose();
	};
}
function yclturn(){
	$.post("./gongdan/int.php?action=yclp&value=turn",$("#xdf").serialize(),function(data){
			$("#tpl-ycl").html(data)
		})
}
function yclsubmit(){
	if(checktextarea()!=false){
		$.post("./gongdan/int.php?action=xiaycldan",$("#xdf").serialize(),function(data){$("#tpl-ycl").html(data)})
	}
}
function yclclose(){
	$("#cnt").css("display","block")
	$("#ycl").css("display","none")
}